<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*,java.sql.*,db.*" contentType="text/html; charset=utf-8" %>
<%
UserSession userSession = (UserSession)session.getAttribute("user"); 
Cookie cook = (Cookie)request.getAttribute("LoginCook");

if (cook!=null){
	response.addCookie(cook);
}

String login_id = null;
String user_id = null;
String login_name = null;
String admin_level = null;
String admin_ent_id = null;

if(userSession!= null){
	login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
	login_name = userSession.getUser_name();
	admin_level = userSession.getAdmin_level();
	admin_ent_id = userSession.getEnt_id();
}

String[] param = new String[2];
param[0]=admin_level;
param[1]="Y";

ArrayList list_l =null;
HashMap map_1 = null;

Connection con=null;
DAO userdao = new DAO();
try {
	con = (new CommonConnect()).getConnection_ds1();
	String queryStr =  QueryManager.getQuery("menu_select.query");
	list_l = userdao.select(con,queryStr,param);


} catch (Exception e) {
	e.printStackTrace();
}finally {
	  try{
		  if (con!=null) con.close();
	  }catch(Exception ee){}
}

String login_id_map = null;
String login_name_map = null;
String login_message = null;

HashMap listMap=(HashMap)request.getAttribute("list_map");

if(listMap!=null){
	login_message=(String)request.getAttribute("login_message");
	
	if(login_message.equals("ID is not member or Password is wrong!")){
%>
	<script>
	alert("ID/비밀번호가 일치하지 않습니다.");
	location.href = "/index.jsp"
	</script>
<%	
	}
	
	HashMap map  = null;
	ArrayList list=null;
	
	
	list=(ArrayList)listMap.get("loginContent");
	if (list!=null && list.size()> 0) {
	 // System.out.println("---------------->>>>list");
	 	map=(HashMap)list.get(0);
	      
	    login_id_map = CommonUtil.nvl(Crypto.DecodeBySType((String)map.get("login_id")));
	    login_name_map = CommonUtil.nvl((String)map.get("login_name"));
	      
	 }
	
	
	Cookie cookie = null;
	String id = "";
	Cookie[] cookies = request.getCookies();
	if (cookies != null) {
		for (int i = 0; i < cookies.length; i++) {
			cookie = cookies[i];
			if (cookie.getName().equals("usid")) {
				id = (String) (cookie.getValue());
			}
		}
	} // IF cookies != null
	String user_ip   = request.getRemoteAddr();
	String d_id = Crypto.DecodeBySType2(id, user_ip);

}
%>
<jsp:include page="/jsp/common/header.jsp"><jsp:param name="submenu_id" value="" /></jsp:include>

<script>
function go_input(){
	var frm = document.mainform;	
	frm.cmd.value='test_input';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();	
}

function go_logout(){
	var frm = document.mainform;	
	frm.cmd.value='logout';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();	
}

function go_index_main(c){
	var frm = document.mainform;	
	frm.cmd.value=c;
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();	
}
</script>

<form name="mainform"  method="post" action = "/speaking.pb" >
<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="admin_ent_id" value="<%=admin_ent_id %>">
</form>

<%if(userSession==null){%>	
<script>go_index_main('admin_intro')</script>
<% }else if(admin_level.equals("4")){ %>
<script>go_index_main('opictest_main')</script>
<%}else{ %>
<script>go_index_main('opic_stats')</script>
<%} %>

<jsp:include page="/jsp/common/top.jsp"></jsp:include>

<!--  
<div id="bodyContainer">
        <div id="contents">
          <div class="index">
            
            <table> 
              <tr>
<%
for (int i=0;list_l.size()-1>i ;i++){	
	map_1=(HashMap)list_l.get(i);
%>          
            <td width="250" align="center" height="30"><a href="#" onclick="go_index_main('<%=(String)map_1.get("command") %>')"><%=(String)map_1.get("menu_name") %></a></td>
            <% 
            //if((list_l.size()-1+i)%2==0){
			//out.println(list_l.size());
			if(i > 0 && i%5==0){
            %></tr><tr><% 
			}
}
%>                        
              </tr>
              
            </table>  
          </div>      
        </div>
      </div>
-->

<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
